Show language: C# VB.NET Both

Stemming And Lemmas

Stemming (finding lemmas) is used to search for word variations. Eg. if the user searches for "tables", they will receive results that include "table" (note that this is more powerful than simple wildcard searching, because it can match shorter as well as longer forms).

The LemmaWeightFactor property in the Configuration is set to 0.5 by default, and this controls by how much lemma matches are weighted in the results. If the user searched for "tables", then occurrences of "table" will weigh half as much as occurrences of "tables", this ranking helps prevent the top results being cluttered with inexact matches to the searched terms.

Languages

You can choose the language to use for stemming in the LemmaLanguage property in the Configuration. Note that stemming algorithms are language specific and so the supported languages may be less numerous than the spelling dictionaries that are also available for the SearchSuggestions control.

English and German lemmas are built-in to the product DLLs, other languages can be downloaded from this page. Unzipped files should be placed in the index directory, and the LemmaLanguage property in Configuration should be set accordingly.

Customization

The Central Event System includes an Action event called "GetWordVariations" which is fired when the search engine needs lemmas. By hooking into this event the lemmas provided by the default generator can be completely overwritten or modified. Note that variations don't necessarily have to be lemmas (shared stems) but can be any words that should be searched for at the same time, such as synonyms and substitutes. For example a company with a furniture polish product named "Shine-O", may like to include "Shine-O" as a variation for "polish".

Hook into the Central Event System
C#
protected void Page_Load(object sender, EventArgs e)

{

    Sr1.Configuration.CentralEventDispatcher.Action += new Keyoti.SearchEngine.Events.ActionEventHandler(CentralEventDispatcher_Action);

}
VB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    AddHandler (Sr1.Configuration.CentralEventDispatcher.Action), AddressOf CentralEventDispatcher_Action

End Sub
Handle the desired event
C#
void CentralEventDispatcher_Action(object sender, Keyoti.SearchEngine.Events.ActionEventArgs e)

{

    if (e.ActionData.Name == Keyoti.SearchEngine.Events.ActionName.GetWordVariations)

    {

        Keyoti.SearchEngine.DataAccess.Word theWord = ((object[])e.ActionData.Data)[0] as Keyoti.SearchEngine.DataAccess.Word;

        ArrayList variations = (e.ActionData.Data as object[])[1] as ArrayList;

        if (theWord.WordContent == "polish")

        {

            string firstVariation = variations[0].ToString();

            variations.Insert(0, "Shine-O");//insert a word we also want to search for

        } 

    }

}
VB.NET
Private Sub CentralEventDispatcher_Action(ByVal sender As Object, ByVal e As Keyoti.SearchEngine.Events.ActionEventArgs)

        If (e.ActionData.Name = Keyoti.SearchEngine.Events.ActionName.GetWordVariations) Then

            Dim theWord As Keyoti.SearchEngine.DataAccess.Word = CType(CType(e.ActionData.Data, Object())(0), Keyoti.SearchEngine.DataAccess.Word)

            Dim variations As ArrayList = CType(CType(e.ActionData.Data, Object())(1), ArrayList)

            If (theWord.WordContent = "polish") Then

                Dim firstVariation As String = variations(0).ToString

                variations.Insert(0, "Shine-O")

                'insert a word we also want to search for

            End If

        End If

    End Sub